package com.itheima.d4_TreeMap;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class Test {
    public static void main(String[] args) {
        Apple a1 = new Apple("A",12.5);
        Apple a2 = new Apple("B",13.6);
        Map<Apple,Integer> maps = new TreeMap<>((o1, o2) -> {
            return Double.compare(o1.getPrice(), o2.getPrice());
        });
        maps.put(a1,10);
        maps.put(a2,10);
        System.out.println(maps);
    }
}

class Apple{
    private String name;
    private double price;

    public Apple() {
    }

    public Apple(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Apple{" +
                "name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}